import { Controller } from 'egg';

class AuditingController extends Controller {

    /**
     * 获取用户列表
     */
    public async searchUserList() {
        const { ctx, ctx: { request } } = this;
        try {
            ctx.validate({
                page: 'string',
                size: 'string',
            }, request.body)
        } catch (e) {
            ctx.body = ctx.helper.responseErrorParam(e.errors[0].message);
            return;
        }
        const result = await ctx.service.auditingService.searchUserList(request.body);
        ctx.body = ctx.helper.responseSuccess('查询成功', result);
    }

    /**
     * 审核用户（通过、禁止）
     */
    public async auditingUser() {
        const { ctx, ctx: { request } } = this;
        try {
            ctx.validate({
                user_id: 'string',
                type: 'type',
            }, request.body)
        } catch (e) {
            ctx.body = ctx.helper.responseErrorParam(e.errors[0].message);
            return;
        }
        await ctx.service.auditingService.auditingUser(request.body);
        ctx.body = ctx.helper.responseSuccess('审核成功');
    }
}
export default AuditingController;